package pub.wkq.api.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import pub.wkq.api.retry.RetryComponent;

import javax.annotation.Resource;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

@Component
@Slf4j
//@Async //全部类开启异步
public class SMSTask {
    @Resource
    private RetryComponent retryComponent;


    @Async
    public Future<Boolean> sendSms(String mobile, String code) {
        boolean res = retryComponent.sendSmsWithRetry();
        log.info("最终的运行结果 res = {}", res);
        //返回 Future 用于获取异步结果
        return new AsyncResult<>(res);
    }

}
